<include file="public@header" />
<script type="text/html" id="files-item-tpl">
	<li id="saved-file{id}">
		<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
		<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
			   style="width: 200px;" title="文件名称">
		<a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
		<a href="javascript:uploadOne('图片上传','#file-{id}','file');">替换</a>
		<a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
	</li>
</script>
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('index')}">资源库列表</a></li>
			<li class="active"><a>编辑资源</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('edit')}">
			<div class="form-group">
				<label for="input-company" class="col-sm-2 control-label"><span class="form-required">*</span>公司名称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-company" readonly value="{$result.company}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-corporation" class="col-sm-2 control-label"><span class="form-required">*</span>法定代表人</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-corporation" required value="{$result.corporation}" name="corporation">
				</div>
			</div>
			<div class="form-group">
				<label for="input-regtime" class="col-sm-2 control-label">成立时间</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control js-bootstrap-date" id="input-regtime" data-max-date="{:date('Y-m-d H:i')}" value="{$result.regtime|date='Y-m-d',###}" required name="regtime">
				</div>
			</div>
			<div class="form-group">
				<label for="input-address" class="col-sm-2 control-label"><span class="form-required">*</span>公司地址</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-address" required value="{$result.address}" name="address">
				</div>
			</div>
			<div class="form-group">
				<label for="input-email" class="col-sm-2 control-label"><span class="form-required">*</span>邮箱</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-email" required value="{$result.email}" name="email">
				</div>
			</div>
			<div class="form-group">
				<label for="input-phone" class="col-sm-2 control-label"><span class="form-required">*</span>联系电话</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-phone" required value="{$result.phone}" name="phone">
				</div>
			</div>
			<div class="form-group">
				<label for="input-scope" class="col-sm-2 control-label"><span class="form-required">*</span>经营范围</label>
				<div class="col-md-6 col-sm-10">
					<textarea class="form-control" id="input-scope" required name="scope">{$result.scope}</textarea>
				</div>
			</div>
			<div class="form-group">
				<label for="input-price" class="col-sm-2 control-label">收购价</label>
				<div class="col-md-6 col-sm-10" style="width:400px;padding: 0 15px;">
					<div class="input-group">
						<span class="input-group-addon">¥</span>
						<input type="number" class="form-control" id="input-price" name="price" required value="{$result.price}">
						<span class="input-group-addon">万元</span>
					</div>
					<p class="help-block">（两位小数）</p>
				</div>
			</div>
			<div class="form-group">
				<label for="input-jyqk" class="col-sm-2 control-label">经营情况</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-jyqk" name="jyqk" value="{$result.jyqk}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-lxr" class="col-sm-2 control-label">联系人</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-lxr" name="lxr" value="{$result.lxr}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-lxrsf" class="col-sm-2 control-label">联系人身份</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-lxrsf" name="lxrsf" value="{$result.lxrsf}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">转让类型</label>
				<div class="col-md-6 col-sm-10">
					<volist name="lists" id="vo">
						<label class="radio-inline">
							<input type="radio" name="attorn" value="{$vo.id}" <eq name="result.attorn" value="$vo.id">checked</eq> > {$vo.name}
						</label>
					</volist>
				</div>
			</div>
			<div class="form-group">
				<label for="input-zryy" class="col-sm-2 control-label">转让原因</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-zryy" name="zryy" value="{$result.zryy}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-jyzk" class="col-sm-2 control-label">经营状况</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-jyzk" name="jyzk" value="{$result.jyzk}">
				</div>
			</div>
			<div class="form-group">
				<label for="sheng" class="col-sm-2 control-label"><span class="form-required">*</span>区域</label>
				<div class="col-md-6 col-sm-10">
					<div class="input-group">
						<span class="input-group-addon">省</span>
						<select class="form-control" id="sheng" name="areas">
							<volist name="areas" id="vo">
								<option value="{$vo.areaid}" <eq name="vo.areaid|substr=###,0,2" value="$result.areas|substr=###,0,2">selected</eq> >{$vo.name}</option>
							</volist>
						</select>
						<span class="input-group-addon">市</span>
						<select class="form-control" id="shi" name="shi">
						</select>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label for="input-selling_price" class="col-sm-2 control-label">销售价</label>
				<div class="col-md-6 col-sm-10" style="width:400px;padding: 0 15px;">
					<div class="input-group">
						<span class="input-group-addon">¥</span>
						<input type="number" class="form-control" id="input-selling_price" name="selling_price" required value="{$result.selling_price}">
						<span class="input-group-addon">万元</span>
					</div>
					<p class="help-block">（两位小数）</p>
				</div>
			</div>
			<div class="form-group">
				<label for="input-files" class="col-sm-2 control-label">资料上传</label>
				<div class="col-md-6 col-sm-10">
					<ul id="files" class="pic-list list-unstyled form-inline">
						<notempty name="result.files">
							<foreach name="result.files" item="vo">
								<php>$file_url=cmf_get_file_download_url($vo['url']);</php>
								<li id="saved-file{$key}">
									<input id="file-{$key}" type="hidden" name="file_urls[]"
										   value="{$vo.url}">
									<input class="form-control" id="file-{$key}-name" type="text"
										   name="file_names[]"
										   value="{$vo.name}" style="width: 200px;" title="文件名称">
									<a id="file-{$key}-preview" href="{$file_url}" target="_blank">下载</a>
									<a href="javascript:uploadOne('文件上传','#file-{$key}');">替换</a>
									<a href="javascript:(function(){$('#saved-file{$key}').remove();})();">移除</a>
								</li>
							</foreach>
						</notempty>
					</ul>
					<a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl');"
					   class="btn btn-sm btn-default">选择文件</a>
				</div>
			</div>
			<div class="form-group">
				<label for="input-type" class="col-sm-2 control-label">类别</label>
				<div class="col-md-6 col-sm-10">
					<label class="radio-inline">
						<input type="radio" name="type" id="input-type" value="1" <eq name="result.type" value="1">checked</eq> > 待投资项
					</label>
					<label class="radio-inline">
						<input type="radio" name="type" id="input-type" value="2" <eq name="result.type" value="2">checked</eq> > 策划案
					</label>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$result.id}" />
					<button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
				</div>
			</div>
		</form>
	</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
	$(function(){
	    $('#sheng').change(function(){
            setshi($('#sheng').val());
		});
        setshi($('#sheng').val(),'{$result.areas}');
	    function setshi(shengid,areasid) {
			$.ajax({
				url:'{:cmf_url("areas/area")}',
				data:{areaid:shengid},
				success:function(data){
				    $('#shi').html('<option value="0">全部市</option>');
				    $.each(data.data,function(k,item){
				        if(item.areaid == areasid) {
                            $('#shi').append('<option value="'+item.areaid+'" selected>'+item.name+'</option>');
						}else{
                            $('#shi').append('<option value="'+item.areaid+'">'+item.name+'</option>');
						}
					})
				}
			})
		}
	})
</script>
</body>
</html>